const BeseUrl = 'https://api-hmugo-web.itheima.net/api/public/v1'
const request = ({ url, ...params }) => {
    let index = 0
    return new Promise((resolve, reject) => {
        uni.showNavigationBarLoading()
        index++
        uni.request({
            ...params,
            url: BeseUrl + url,
            success: (res) => {
                resolve(res)
            },
            fail: (err) => {
                reject(err)
            },
            complete: () => {
                index--
                if (index === 0) {
                    uni.hideNavigationBarLoading()
                }
            }
        });
    })

}
export default request